package com.lhf.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

@Configuration
@EnableWebMvc
@ComponentScan(value = {"com.lhf.config","com.lhf.controller"})
public class MVCConfig extends WebMvcConfigurerAdapter {
    /**
     * 视图解析器
     * @param pc
     * @return
     */
    @Bean
    public InternalResourceViewResolver internalResourceViewResolver(PropsConfig pc){
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix(pc.getPrefix());
        resolver.setSuffix(pc.getSuffix());
        return resolver;
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
}
